<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {

	public function index(){
		$this->display('index/login');

	}

	public function login(){
		if(IS_POST){
            $user = M('Admin')->where(array('username' =>I('username')))->find();
            if($user && $user['password'] == I('password','','md5')){
                session('admin',$user['username']);
                session('password',$user['password']);
                $this->redirect('index/index');                
            }else{                
                $this->error('账号或密码错',U('login/index'),2);
            }
        }
	}

	public function loginout(){
		session('admin',null);
        $this->success('操作完成','index/index',true);
	}


}